import React, { useEffect, useRef, useState } from "react";
var T = null
function useCountDown(n) {
    let [time, setTime] = useState(n)
    useEffect(() => {
        T = setInterval(() => {
            setTime(t => t - 1)
        }, 1000)
    }, [])
    return time
}

function Timer(n) {
    const time = useCountDown(n);


    return <span>{time <= 0 ? '活动开始' : `距离活动结束剩余${time}秒`}</span>
}

export default Timer